module Lockdown
  module TestHelper
    include Lockdown::Session
    def valid_profile_attributes
      { :id => 1,
        :full_name => "Quentin Quire",
        :email => 'quire@qi.com', 
        :company_name => 'Quire Industries',
        :updated_by => 1
      }
    end
    
    #
    # Login is required to be unique so using a random string.
    #
    def valid_user_attributes
      { :id => 1,
        :login => String.random, 
        :password => 'quire', 
        :password_confirmation => 'quire',
        :updated_by => 1
      }
    end
    
    def valid_user_object
      usr = User.new(valid_user_attributes)
      usr.profile = Profile.new(valid_profile_attributes)
      usr
    end
    
    
    def login_as_administrator
      usr = User.new(valid_user_attributes)
      usr.profile = new_profile
      set_session_user(usr)
      session[:permissions] = UserGroup[:administrators]
    end
    
    private
      def new_profile
        profile = Profile.new(valid_profile_attributes)
        profile.id = 1
        profile
      end
  end
end
